package org.jetnuke.dao.hsqldb;

import org.apache.log4j.Logger;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

import net.jforum.JForumExecutionContext;
import net.jforum.util.preferences.SystemGlobals;

import org.jetnuke.dao.generic.GenericBlogPostDAO;

public class HsqldbBlogPostDAO extends GenericBlogPostDAO {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger
			.getLogger(HsqldbBlogPostDAO.class);

	public List retrievePublishByUser(int id, int maxnumberpost)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("retrievePublishByUser(int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext
				.getConnection()
				.prepareStatement(
						SystemGlobals
								.getSql("BlogPostModel.selectPublishByUserLimit"));
		p.setInt(1, maxnumberpost);
		p.setInt(2, id);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("retrievePublishByUser(int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

}
